While translating the Accelerating Ray Tracing Using Metal sample project into Swift, I have run into an issue within the createAccelerationStructures function.
I am trying to fill in the first three rows of the instance transformation matrix. In the Objective C example, it looks like:
for (int column = 0; column < 4; column++)
	for (int row = 0; row < 3; row++)
		instanceDescriptors[instanceIndex].transformationMatrix.columns[column][row] = instance.transform.columns[column][row];
The matrix targeted is a MTLPackedFloat4x3. It has defied me pulling out the needed elements from my instance transform and placing them in the descriptor. I have tried the obvious:
for column in 0..<( 4 )
	{
	for row in 0..<( 3 )
		{
		anInstanceDescriptorPointer.pointee.transformationMatrix.columns[column][row] = aNodeInstance.transform.columns[column][row]
		}
	}
I have tried more obscure ideas related to simd matrices and Swift. The compiler errors generally warn me that MTLPackedFloat4x3 has no subscripts.
Question - Is there an accepted way to assign three rows from the instance transform to the descriptor transformationMatrix in Swift?
Thank you for your earlier help with all of this. I should mention that the new intersector feature in Metal has worked really well for me when feeding it a primitiveaccelerationstructure. Very elegant! But using instances seems to offer more flexibility going forward.
Thank you very much!